#ifndef HEIGHTFIELD_HPP
#define HEIGHTFIELD_HPP

#include <valarray>

#include <Inventor/nodes/SoSeparator.h>

#include "cutter.hpp"
#include "notifiers.hpp"

class heightfield;


class simplefacetter
{
public:
  simplefacetter(heightfield *m);
  void facet(facet_note *tic=NULL);
  SoSeparator* Result();


  SoSeparator* result;
  heightfield* model;
};

  
class heightfield
{
public:
  
  heightfield();
  virtual ~heightfield();
  
  heightfield(double _xmin, double _ymin,
	     long _nx, long _ny,
	     double _dx, double _dy); 

  void blank(double xmin, double xmax,
	     double ymin, double ymax,
	     double zmin, double zmax,
	     double dx, double dy );

  // void unhash(long ,long*, long*);
  
  long hand(long ix,long iy) const;
  long dhand(double x, double y) const;
  
  
  long referx(double x) const;
  long refery(double y) const;
  
  double unrefx(long ix) const;
  double unrefy(long iy) const;

  void apply_cutter(cutter*);
  
  simplefacetter facet;
  
  double
  xmin, xmax,
    ymin, ymax,
    zmin, zmax;
  
  double dx, dy;
  
  long nx,ny;
  
  // valarray<double> f;
  double *f;
  
};



#endif
